// 带小时
// 处理时间函数
export const formatTimes = (val) => {
  // console.log(val)
  const dateObj = new Date(val);
  const year = dateObj.getUTCFullYear();
  const month = ("0" + (dateObj.getUTCMonth() + 1)).slice(-2);
  const day = ("0" + dateObj.getUTCDate()).slice(-2);
  const hours = ("0" + dateObj.getUTCHours()).slice(-2);
  const minutes = ("0" + dateObj.getUTCMinutes()).slice(-2);
  const seconds = ("0" + dateObj.getUTCSeconds()).slice(-2);
  return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
};
// 不带小时
export const formatTime = (timestamp) => {
  // 创建一个Date对象，参数为时间戳
  const date = new Date(timestamp); // 使用Date对象提供的方法获取年、月、日、小时、分钟和秒

  const year = date.getFullYear();
  const month = date.getMonth() + 1; //月份是从0开始的，需要加1
  const day = date.getDate();

  return `${year}-${month < 10 ? "0" + month : month}-${
    day < 10 ? "0" + day : day
  }`;
};
